input = [1,8,6,2,5,4,8,3,7]

def max_container(input):
    i=0
    j=len(input)-1
    res = 0
    while i<j:
        hi = input[i]
        hj = input[j]
        w = j-i
        if hi>hj:
            cur = hj*w
            j-=1
        else:
            cur = hi*w
            i+=1
        if cur > res:
            res = cur
    return res

print(max_container(input))